package com.itheima.aop_xml;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

//增强类
@Component
@Aspect //让本类作为一个切面
public class Advice {

    public void writeLog() {
        System.out.println("记录日志");
    }

    @Before("execution(* com.itheima.aop_xml..add*(..))")
    public void before() {
        System.out.println("前面记录日志");
    }

    @AfterReturning("execution(* com.itheima.aop_xml..delete*(..))")
    public void afterReturning() {
        System.out.println("后面记录日志");
    }

    @Around("execution(* com.itheima.aop_xml..query)")
    public void around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("环绕增强前");
        joinPoint.proceed();  //切到原来的目标方法,进行执行
        System.out.println("环绕增强后");
    }

    @After("execution(* com.itheima.aop_xml..bat*(..))")
    public void after() {
        System.out.println("最终记录日志");
    }


    @AfterThrowing("execution(* com.itheima.aop_xml..update*(..))")
    public void thowable() {
        System.out.println("异常记录日志");
    }
}